const db = require('../db/index')



//添加课程逻辑处理
exports.AddCurriculum = (req,res) => {
    const userinfo = req.body
    const  sql = 'insert into curriculum set ?'
    db.query(sql,{number:userinfo.number,coursename:userinfo.coursename,credit:userinfo.credit,theory:userinfo.theory,practice:userinfo.practice,check:userinfo.check})
        .then(([results,fields])=>{
              res.send({message:"课程添加成功!!!",code:200})
        }).catch(reason => {
        res.send(reason)
    })
}

//查询课程逻辑处理
exports.GetCurriculum = (req,res) => {
    const  sql = 'select * from  curriculum '
    db.query(sql).then(([results,fields])=>{
        res.send(results)
    }).catch(reason => {
        res.send(reason)
    })
}

//删除课程逻辑处理
exports.DeleteCurriculum = (req,res) => {
    const sql = 'delete from curriculum where id = ?'
    db.query(sql,req.body).then(([results,fields])=>{
        res.send({message:"删除课程成功!!!",code:200})
    }).catch(reason => {
        res.send(reason)
    })
}

//修改课程逻辑处理
exports.UploadCurriculum = (req,res) => {

}